//
// Created by v on 19-6-6.
//

#ifndef OPENGLFUNC_CMVIDEODECODER_H
#define OPENGLFUNC_CMVIDEODECODER_H

#include <iostream>

#ifdef __cplusplus
extern "C" {
#endif

#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"

#ifdef __cplusplus
}
#endif

class CMVideoDecoder {
public:
    CMVideoDecoder();
    virtual ~CMVideoDecoder();

    int init();

    int open();
    int close();

    int decoder(char **output, int *outputlen, int *width, int *height);

protected:
    int initCodec();

    std::string    m_filename;

private:
    char        *m_buf;
    int          m_buflen, m_datalen;

    AVFormatContext *m_formatContext;
    AVCodecContext  *m_codecContext;

    AVCodec         *m_codec;
    int              m_codecOpen;

    AVFrame          *m_frame;
};


#endif //OPENGLFUNC_CMVIDEODECODER_H
